package com.mathdroid.gui.main.abilities;

import java.util.LinkedList;

import com.mathdroid.gui.componentlist.AComponentListElement;
import com.mathdroid.gui.componentlist.IComponentListModel;

/**
 * Ability list model.
 */
public final class AbilityListModel implements IComponentListModel {
	
	/**
	 * The element list.
	 */
	private final LinkedList<AComponentListElement> list = 
		new LinkedList<AComponentListElement>();

	@Override
	public int addElement(final AComponentListElement e) {
		final int index = this.list.size();
		
		this.list.add(e);
		
		return index;
	}

	@Override
	public int removeElement(final AComponentListElement e) {
		int index = this.list.indexOf(e);
		
		this.list.remove(index);
		
		return index;
	}

	@Override
	public void clear() {
		this.list.clear();
	}

	@Override
	public int size() {
		return this.list.size();
	}

}
